<template>
    <div>
        <main-book-list :listHeight="contentHeight" :bookList="bookList"
                        :loading="loading"
                        @onLoading="onloading"
                        @changDefaultCover="changDefaultCover"
                        @deleteBook="deleteBook">
        </main-book-list>
    </div>
</template>

<script>
    import MainBookList from './MainBookList'
    import {getCache, setCache} from '../../util/storageUtils';
    import {SHELF_BOOK} from '../../store/mutation-types';
    import {SET_BOOK} from '../../store/mutations';

    export default {
        components: {MainBookList},
        name: "book-self",
        props: {
            title: '',
            contentHeight: {
                type: Number,
                default: 1144
            },
        },
        data() {
            return {
                bookList: [],
                loading: false,
            }
        },
        mounted() {
            getCache(SHELF_BOOK).then(value => {
                this.bookList = JSON.parse(value) || {};
            });

        },
        methods: {
            minibarLeftButtonClick() {
            },
            minibarRightButtonClick() {
                modal.toast({'message': 'click rightButton!', 'duration': 1});
            },
            onloading() {

            },
            changDefaultCover() {

            },
            deleteBook(obj){
                delete this.bookList[obj.bookId];
                SET_BOOK(this.bookList);
            }
        }
    }
</script>

<style scoped>

</style>